/**
 * 用户相关API
 */
import api from './index'

export const userAPI = {
  // 账号密码登录
  login: (phone, password) => {
    const qs = new URLSearchParams({
      phone,
      password_hash: password
    }).toString()
    return fetch(`http://127.0.0.1:8000/user/login?${qs}`)
      .then(res => res.json())
  },
  
  // 获取钉钉登录URL
  getDingTalkUrl: () => fetch('http://localhost:8000/user/baidu').then(res => res.json()),
  
  // 检查是否为管理员
  isAdmin: () => api.get('/user/is_admin'),
  
  // 获取当前用户信息
  getCurrentUser: () => api.get('/user/me'),
}

